<template>
  <div style="margin-top: 20px">
    <el-table
      :data="getPage"
      border
      height="500"
      style="width: 100%">
      <el-table-column v-for="item in columnName" :key="item.id" :label="item.label" >
        <template slot-scope="scope">
          <span>{{scope.row[item.prop]}}</span>
        </template>
      </el-table-column>
      <el-table-column
        fixed="right"
        label="操作"
        width="100">
        <template slot-scope="scope">
          <el-button @click="handleClick(scope.row)" type="text" size="small">查看</el-button>
          <el-button type="text" size="small">编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[5, 10, 20, 40]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="total">
    </el-pagination>


  </div>
</template>

<script>
    export default {

      props:{
        currentPage:1, //初始页
        pageSize:10,    //    每页的数据
        total:0,    //    每页的数据
        getPage:[],
        columnName:[
        ],

      },
        name: "EleTable",
      data(){
          return {

        }
      }
      ,methods:{
        handleClick(data){
          console.log(data);
        },

        handleSizeChange(val) {
          this.pageSize=val;
          this._page();
        },
        handleCurrentChange(val) {
          this.currentPage=val;
          this._page();
        },

      }
    }
</script>

<style scoped>

</style>
